export const systemMenu = [
  {
    menuKeyCode: "000000",
    upperMenuKeyCode: "999999",
    menuKeyName: "系统菜单",
    children: [
      {
        menuKeyCode: "010000",
        upperMenuKeyCode: "000000",
        menuKeyName: "监控面板",
        children: [],
      },
      {
        menuKeyCode: "020000",
        upperMenuKeyCode: "000000",
        menuKeyName: "缓存管理",
        children: [
          {
            menuKeyCode: "020100",
            upperMenuKeyCode: "020000",
            menuKeyName: "缓存配置",
            children: [
              {
                menuKeyCode: "020101",
                upperMenuKeyCode: "020100",
                menuKeyName: "新增",
                children: [],
              },
              {
                menuKeyCode: "020102",
                upperMenuKeyCode: "020100",
                menuKeyName: "编辑",
                children: [],
              },
              {
                menuKeyCode: "020103",
                upperMenuKeyCode: "020100",
                menuKeyName: "作废",
                children: [],
              },
            ],
          },
          {
            menuKeyCode: "020200",
            upperMenuKeyCode: "020000",
            menuKeyName: "缓存数据",
            children: [
              {
                menuKeyCode: "020201",
                upperMenuKeyCode: "020200",
                menuKeyName: "清除缓存",
                children: [],
              },
            ],
          },
          {
            menuKeyCode: "020300",
            upperMenuKeyCode: "020000",
            menuKeyName: "系统缓存更新",
            children: [
              {
                menuKeyCode: "020301",
                upperMenuKeyCode: "020300",
                menuKeyName: "管理后台系统缓存",
                children: [],
              },
              {
                menuKeyCode: "020302",
                upperMenuKeyCode: "020300",
                menuKeyName: "基础代码缓存更新",
                children: [],
              },
              {
                menuKeyCode: "020303",
                upperMenuKeyCode: "020300",
                menuKeyName: "路由配置缓存更新",
                children: [],
              },
              {
                menuKeyCode: "020304",
                upperMenuKeyCode: "020300",
                menuKeyName: "地址配置缓存更新",
                children: [],
              },
              {
                menuKeyCode: "020305",
                upperMenuKeyCode: "020300",
                menuKeyName: "加签配置缓存更新",
                children: [],
              },
            ],
          },
        ],
      },
      {
        menuKeyCode: "030000",
        upperMenuKeyCode: "000000",
        menuKeyName: "对账管理",
        children: [
          {
            menuKeyCode: "030100",
            upperMenuKeyCode: "030000",
            menuKeyName: "对账开业配置",
            children: [
              {
                menuKeyCode: "030101",
                upperMenuKeyCode: "030100",
                menuKeyName: "新增",
                children: [],
              },
              {
                menuKeyCode: "030102",
                upperMenuKeyCode: "030100",
                menuKeyName: "编辑",
                children: [],
              },
              {
                menuKeyCode: "030103",
                upperMenuKeyCode: "030100",
                menuKeyName: "作废",
                children: [],
              },
            ],
          },
          {
            menuKeyCode: "030200",
            upperMenuKeyCode: "030000",
            menuKeyName: "对账任务管理",
            children: [
              {
                menuKeyCode: "030201",
                upperMenuKeyCode: "030200",
                menuKeyName: "创建任务",
                children: [],
              },
              {
                menuKeyCode: "030202",
                upperMenuKeyCode: "030200",
                menuKeyName: "任务重启",
                children: [],
              },
              {
                menuKeyCode: "030203",
                upperMenuKeyCode: "030200",
                menuKeyName: "批量下载",
                children: [],
              },
              {
                menuKeyCode: "030204",
                upperMenuKeyCode: "030200",
                menuKeyName: "下载",
                children: [],
              },
            ],
          },
          {
            menuKeyCode: "030300",
            upperMenuKeyCode: "030000",
            menuKeyName: "对账源查询",
            children: [
              {
                menuKeyCode: "030301",
                upperMenuKeyCode: "030300",
                menuKeyName: "添加数据源",
                children: [],
              },
              {
                menuKeyCode: "030302",
                upperMenuKeyCode: "030300",
                menuKeyName: "重启数据解析",
                children: [],
              },
            ],
          },
          {
            menuKeyCode: "030400",
            upperMenuKeyCode: "030000",
            menuKeyName: "对账错误查询",
            children: [],
          },
        ],
      },
      {
        menuKeyCode: "040000",
        upperMenuKeyCode: "000000",
        menuKeyName: "基础配置管理",
        children: [
          {
            menuKeyCode: "040100",
            upperMenuKeyCode: "040000",
            menuKeyName: "接口类型管理",
            children: [
              {
                menuKeyCode: "040101",
                upperMenuKeyCode: "040100",
                menuKeyName: "新增",
                children: [],
              },
              {
                menuKeyCode: "040102",
                upperMenuKeyCode: "040100",
                menuKeyName: "编辑",
                children: [],
              },
              {
                menuKeyCode: "040103",
                upperMenuKeyCode: "040100",
                menuKeyName: "作废",
                children: [],
              },
            ],
          },
          {
            menuKeyCode: "040200",
            upperMenuKeyCode: "040000",
            menuKeyName: "保协地址管理",
            children: [
              {
                menuKeyCode: "040201",
                upperMenuKeyCode: "040200",
                menuKeyName: "新增",
                children: [],
              },
              {
                menuKeyCode: "040202",
                upperMenuKeyCode: "040200",
                menuKeyName: "编辑",
                children: [],
              },
              {
                menuKeyCode: "040203",
                upperMenuKeyCode: "040200",
                menuKeyName: "作废",
                children: [],
              },
            ],
          },
          {
            menuKeyCode: "040300",
            upperMenuKeyCode: "040000",
            menuKeyName: "预警配置",
            children: [
              {
                menuKeyCode: "040301",
                upperMenuKeyCode: "040300",
                menuKeyName: "新增",
                children: [],
              },
              {
                menuKeyCode: "040302",
                upperMenuKeyCode: "040300",
                menuKeyName: "编辑",
                children: [],
              },
              {
                menuKeyCode: "040303",
                upperMenuKeyCode: "040300",
                menuKeyName: "作废",
                children: [],
              },
            ],
          },
          {
            menuKeyCode: "040400",
            upperMenuKeyCode: "040000",
            menuKeyName: "查询比阈值配置",
            children: [
              {
                menuKeyCode: "040401",
                upperMenuKeyCode: "040400",
                menuKeyName: "新增",
                children: [],
              },
              {
                menuKeyCode: "040402",
                upperMenuKeyCode: "040400",
                menuKeyName: "编辑",
                children: [],
              },
              {
                menuKeyCode: "040403",
                upperMenuKeyCode: "040400",
                menuKeyName: "作废",
                children: [],
              },
            ],
          },
          {
            menuKeyCode: "040500",
            upperMenuKeyCode: "040000",
            menuKeyName: "加签业务管理",
            children: [
              {
                menuKeyCode: "040501",
                upperMenuKeyCode: "040500",
                menuKeyName: "新增",
                children: [],
              },
              {
                menuKeyCode: "040502",
                upperMenuKeyCode: "040500",
                menuKeyName: "编辑",
                children: [],
              },
              {
                menuKeyCode: "040503",
                upperMenuKeyCode: "040500",
                menuKeyName: "作废",
                children: [],
              },
            ],
          },
          {
            menuKeyCode: "040600",
            upperMenuKeyCode: "040000",
            menuKeyName: "报价次数配置",
            children: [
              {
                menuKeyCode: "040601",
                upperMenuKeyCode: "040600",
                menuKeyName: "新增",
                children: [],
              },
              {
                menuKeyCode: "040602",
                upperMenuKeyCode: "040600",
                menuKeyName: "编辑",
                children: [],
              },
              {
                menuKeyCode: "040603",
                upperMenuKeyCode: "040600",
                menuKeyName: "作废",
                children: [],
              },
            ],
          },
        ],
      },
      {
        menuKeyCode: "050000",
        upperMenuKeyCode: "000000",
        menuKeyName: "统计管理",
        children: [
          {
            menuKeyCode: "050100",
            upperMenuKeyCode: "050000",
            menuKeyName: "请求日志查询",
            children: [],
          },
          {
            menuKeyCode: "050200",
            upperMenuKeyCode: "050000",
            menuKeyName: "查询比统计",
            children: [
              {
                menuKeyCode: "050201",
                upperMenuKeyCode: "050200",
                menuKeyName: "清单导出",
                children: [],
              },
            ],
          },
          {
            menuKeyCode: "050300",
            upperMenuKeyCode: "050000",
            menuKeyName: "利用率统计",
            children: [
              {
                menuKeyCode: "050301",
                upperMenuKeyCode: "050300",
                menuKeyName: "清单导出",
                children: [],
              },
            ],
          },
        ],
      },
      {
        menuKeyCode: "060000",
        upperMenuKeyCode: "000000",
        menuKeyName: "安全操作日志",
        children: [],
      },
      {
        menuKeyCode: "070000",
        upperMenuKeyCode: "000000",
        menuKeyName: "权限管理",
        children: [
          {
            menuKeyCode: "070100",
            upperMenuKeyCode: "070000",
            menuKeyName: "人员权限查询",
            children: [
              {
                menuKeyCode: "070101",
                upperMenuKeyCode: "070100",
                menuKeyName: "清单导出",
                children: [],
              },
            ],
          },
          {
            menuKeyCode: "070200",
            upperMenuKeyCode: "070000",
            menuKeyName: "人员权限配置",
            children: [
              {
                menuKeyCode: "070201",
                upperMenuKeyCode: "070200",
                menuKeyName: "人员列表编辑",
                children: [],
              },
              {
                menuKeyCode: "070202",
                upperMenuKeyCode: "070200",
                menuKeyName: "人员权限列表编辑",
                children: [],
              },
              {
                menuKeyCode: "070203",
                upperMenuKeyCode: "070200",
                menuKeyName: "人员权限列表删除",
                children: [],
              },
            ],
          },
          {
            menuKeyCode: "070300",
            upperMenuKeyCode: "070000",
            menuKeyName: "角色权限配置",
            children: [
              {
                menuKeyCode: "070301",
                upperMenuKeyCode: "070300",
                menuKeyName: "新增&编辑",
                children: [],
              },
              {
                menuKeyCode: "070302",
                upperMenuKeyCode: "070300",
                menuKeyName: "删除",
                children: [],
              },
            ],
          },
        ],
      },
    ],
  },
];

export const rolelist = [
  {
    roleName: "系统管理员",
    roleCode: "111111",
    ownerMenuKeyCodeList: [
      "010000",
      "020100",
      "020101",
      "020200",
      "020300",
      "030100",
      "030200",
      "030300",
      "030400",
      "040200",
      "040400",
      "040500",
      "040600",
      "050100",
      "050200",
      "050300",
      "060000",
      "070100",
      "070200",
      "070300"
    ],
  },
  {
    roleName: "总公司管理员",
    roleCode: "222222",
    ownerMenuKeyCodeList: [
      "010000",
      "010100",
      "010101",
      "010102",
      "010103",
      "010200",
      "010201",
      "010202",
      "010203",
      "020000",
      "020100",
      "020101",
      "020102",
      "020103",
      "020200",
      "020201",
      "020202",
      "020203",
    ],
  },
  {
    roleName: "机构管理员",
    roleCode: "333333",
    ownerMenuKeyCodeList: [
      "010000",
      "010100",
      "010101",
      "010102",
      "010103",
      "010200",
      "010201",
      "010202",
      "010203",
    ],
  },
  {
    roleName: "业务人员",
    roleCode: "444444",
    ownerMenuKeyCodeList: ["010103", "010202"],
  },
  {
    roleName: "开发人员",
    roleCode: "555555",
    ownerMenuKeyCodeList: [
      "010000",
      "020000",
      "020100",
      "020200",
    ],
  },
];

export const getTreeFormat = (menuTree) => {
  const menuArray = JSON.parse(JSON.stringify(menuTree));

  const newMenuTree = menuArray.map((treeItem) => {
    const newTreeItem = {
      upperMenuKeyCode: treeItem.upperMenuKeyCode,
      menuKeyName: treeItem.menuKeyName,
      menuKeyCode: treeItem.menuKeyCode,
    };

    if (treeItem.children) {
      newTreeItem.children = getTreeFormat(treeItem.children);
    }

    return newTreeItem;
  });

  return newMenuTree;
};
